package com.example.demo.control;

import com.alibaba.fastjson.JSON;
import com.example.demo.pojo.Admin;
import com.example.demo.pojo.Backlogin;
import com.example.demo.service.BackLoginService;
import com.github.pagehelper.PageInfo;
import javafx.scene.control.Alert;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@ResponseBody
@Controller
public class BackLoginControl {
    @Resource
    BackLoginService backLoginService;
    @PostMapping("/c/backusershow")
    public String backloginshow(String page,String name){
        PageInfo<Admin> backlogininfo=backLoginService.backlogininfo(Integer.parseInt(page),5,-1,name,"");
        return JSON.toJSONString(backlogininfo);
    }

    @PostMapping("/c/backusershow/update")
    public String updateshow(String name,String account,String state,String pwd,String seq,String page,String backraleid){
       String a= backLoginService.backupdate(name,account,state,pwd,seq,page,Integer.parseInt(backraleid));

        return JSON.toJSONString(a);
    }
    @PostMapping("/c/backusershow/delete")
    public String deleteshow(String seq){
        backLoginService.backdelete(seq);
        return JSON.toJSONString("删除成功");
    }

    @PostMapping("/c/backusershow/insert")
    public String insertshow(String name,String pwd,String account,String role){
       String message= backLoginService.backinsert(name,pwd,account,role);
        return JSON.toJSONString(message);
    }

    @PostMapping("/backlogin")
    public String backLogin(String count, String password, String yzm, HttpSession httpSession){
        String a=backLoginService.loginuril(count,password,yzm,httpSession);
        return JSON.toJSONString(a);
    }
}
